package com.c.ctgproject.adapter.storage

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.storage.StoragePartsOutEntity
import com.c.ctgproject.mode.MyConstants
import com.c.ctgproject.ui.storage.part.StoragePartsOutDetailActivity
import org.jetbrains.anko.startActivity

/**
 *作者:LiBW
 *创建日期: 2020/9/11
 *描述:仓储 配件出库 adapter
 */
class StoragePartsOutAdapter(private val context: Context, private val mList: List<StoragePartsOutEntity.DataBean.ListBean>) : RecyclerView.Adapter<StoragePartsOutAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_storage_part_out_list, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = mList[position]
        holder.mOrderIdTV.text=data.partsSalesNo.toString()
        holder.mTimeTV.text = data.auditTime.toString()
        holder.mCarOwnerTV.text = data.carCode.toString()
        //配件出库查看详情
        holder.mItemCV.setOnClickListener {
            context.startActivity<StoragePartsOutDetailActivity>(
                MyConstants.ENTITY to data
            )
        }


    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mItemCV: CardView = itemView.findViewById(R.id.mItemCV)
        val mTimeTV: TextView = itemView.findViewById(R.id.mTimeTV)
        val mCarOwnerTV: TextView = itemView.findViewById(R.id.mCarOwnerTV)
        val mOrderIdTV: TextView = itemView.findViewById(R.id.mOrderIdTV)
    }
}